<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
 */

Auth::routes();

Route::get('/', function () {
    return view('welcome');
});

/*Route::view('/welcome', 'welcome', ['name' => 'Taylor']);*/

Route::get('/home', 'HomeController@index')->name('home');

//前台->user模块
Route::group(['prefix' => 'user', 'namespace' => 'user', 'middleware' => 'auth'], function () {
    Route::get('/', 'IndexController@index');
});

//后台管理员
Route::get('admin/login', 'Admin\AuthController@adminlogin');
Route::post('admin/login', 'Admin\AuthController@login');
Route::post('admin/logout', 'Admin\AuthController@logout');

//后台模块
Route::prefix('admin')->namespace('Admin')->middleware(['admin'])->group(function () {
    Route::get('/', 'IndexController@index');
    Route::post('/item', 'IndexController@item');
    Route::get('info', 'IndexController@info');
    Route::get('page', 'IndexController@page');
    Route::resource('/order', 'OrderController');
    Route::get('/excel', 'IndexController@excel');
    Route::post('/update', 'IndexController@update');
    Route::get('/web', 'IndexController@web');
    Route::get('/tooltip', 'IndexController@tooltip');
    Route::post('/web', 'IndexController@doweb');
    Route::post('/add', 'IndexController@doadd');
    Route::post('/checkEmail', 'IndexController@checkEmail');
    Route::get('/web4', 'IndexController@web4');
    Route::post('/property', 'IndexController@property');
    Route::get('/react', 'IndexController@react');
    Route::post('/jsonp', 'IndexController@jsonp');
    Route::get('/excel/export','ExcelController@export');
    Route::get('/excel/import','ExcelController@import');
    Route::post('/excel/import','ExcelController@importdata');
    Route::get('/test', 'IndexController@test');
    Route::get('/upload', 'IndexController@upload');
    Route::post('/upload', 'IndexController@uploader');
    Route::post('/file', 'FileController@upload');
});

Route::get('/app', 'HomeController@app');

Route::get('/redirect', function () {
    $query = http_build_query([
        'client_id' => '1',
        'redirect_uri' => 'http://kf.mdshop.com',
        'response_type' => 'code',
        'scope' => '',
    ]);

    return redirect('/oauth/authorize?'.$query);
});